home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / ASSEMBLE / H235A.ZIP / ASM_0_M.ZIP / FASTBUFF.TXT < prev    next >
Text File  |  1987-11-26  |  44KB  |  1,057 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                                    FASTBUFF v2.0
  8.                                           
  9.                             Do-It-All Keyboard Enhancer
  10.                                           
  11.                                    David Steiner
  12.                                    November 1987
  13.             
  14.             
  15.             
  16.             The only thing you really need to know in order to use
  17.             FASTBUFF is that to install it you type FASTBUFF and hit the
  18.             ENTER key.  To see the results just hold down a key and
  19.             watch how fast it goes.  If you run into problems with a
  20.             program that doesn't like FASTBUFF then you may want to look
  21.             over this documentation a little closer.
  22.             
  23.             Even if you're not entirely sure you like the idea of such a
  24.             keyboard enhancement program, at least give FASTBUFF a trial
  25.             run.  After all, its a free program.  You will quite likely
  26.             find it frustrating to go back to the normal repeat rate and
  27.             buffer size.
  28.             
  29.             Version 2.0 is a fairly large improvement over version 1.0,
  30.             even though this one has been released fairly quickly after
  31.             the first.  The only bug fix was related to typing in
  32.             characters via the numeric keypad.  It seems that the repeat
  33.             function always ended up set, and wouldn't stop till you hit
  34.             another key.
  35.             
  36.             
  37.             
  38.                                     REQUIREMENTS
  39.             
  40.             FASTBUFF was written on an IBM XT compatible computer.  It
  41.             should work with true IBM PC's just fine.  I've also tested
  42.             it on AT compatibles, and it seems to work fine.  The video
  43.             blanking works fine for CGA and monochrome systems, but not
  44.             EGA.  I doubt it will work for other video cards either.
  45.             I'll try to provide support for them at a later date when I
  46.             have time.  If you don't have a video card that is
  47.             supported, it is best to disable this function.
  48.             
  49.             As far as memory is concerned, FASTBUFF only eats up 1500
  50.             bytes when its using a 100 character buffer.  Even if you
  51.             set the buffer as large as it will go (269 characters)
  52.             FASTBUFF still only take up about 1800 bytes.
  53.             
  54.             As usual, there are some restrictions on what order you load
  55.             FASTBUFF.  Although it is a well-behaved resident program
  56.             you still get the best results if you load it early.  This
  57.             has to do with who "hooks" which vectors and will be
  58.             discussed below in more detail.  Some programs, however, are
  59.             very low-level and should be loaded before FASTBUFF.  Such
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.             programs include the keyboard drivers supplied with MS-DOS
  74.             (KEYxx.COM).
  75.             
  76.             
  77.                                       FEATURES
  78.             
  79.             Variable Size Keyboard Buffer:
  80.                  FASTBUFF takes control of the keystroke interrupt in
  81.                  order to allow you to set the size of buffer you like.
  82.                  The default is 100 characters, but may range from 25 to
  83.                  269 characters.
  84.             
  85.             Increased Key Repeat Rate:
  86.                  By using the timer interrupt we are able to modify how
  87.                  fast keys are repeated.  When FASTBUFF is activated you
  88.                  may select between a repeat rate of 18 or 36 characters
  89.                  per second.  Unlike most key quickeners that I've seen,
  90.                  FASTBUFF has a fairly smooth repeat rate even in its
  91.                  fast mode.  Note that you may also select the normal
  92.                  repeat rate by turning FASTBUFF off.
  93.             
  94.             Anti-skid Braking:
  95.                  Given a large buffer and fast repeat rate you could get
  96.                  way ahead of your application when holding a key down.
  97.                  FASTBUFF uses a simple but effective method of
  98.                  preventing this: it doesn't put repeated characters
  99.                  into the buffer until the application program is ready
  100.                  (i.e. the buffer is empty).
  101.             
  102.             Screen Blanking:
  103.                  If you leave your computer unattended for over fifteen
  104.                  minutes FASTBUFF will automatically blank the video
  105.                  screen in order to avoid "burning" characters into the
  106.                  display screen.  The screen may be restored by pressing
  107.                  any key.
  108.             
  109.             Repeat Characters Entered Through the Alt-Keypad:
  110.                  The IBM will allow you to enter characters by holding
  111.                  the ALT key down and typing the ASCII character number
  112.                  on the numeric keypad.  When you release the ALT key
  113.                  the character is inserted at the cursor position.
  114.                  FASTBUFF also provides a method of repeating the key
  115.                  entered this way.
  116.             
  117.             Enter Graphics Characters With the Alt-Keypad:
  118.                  Some of us poor folks with IBM compatibles have a BIOS
  119.                  that gets confused when entering graphics characters
  120.                  via the keypad (character numbers over 127).  FASTBUFF
  121.                  takes control of this function and returns these
  122.                  characters correctly.  This fix also pertains to
  123.                  compatibles that do not return the normal scan code (0)
  124.                  for these characters.
  125.             
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.             Disable FASTBUFF:
  140.                  It is possible that you may need to use a program that
  141.                  doesn't seem to like FASTBUFF.  To account for this
  142.                  possibility you may turn off the FASTBUFF functions in
  143.                  order to use these programs.  After leaving the
  144.                  conflicting application, you may re-enable FASTBUFF
  145.                  again.
  146.             
  147.             
  148.                                RUN-TIME CONTROL KEYS
  149.             
  150.             While FASTBUFF is resident you have several options for the
  151.             way it controls your keyboard.  First we'll cover the option
  152.             for clearing the FASTBUFF keyboard buffer:
  153.             
  154.             
  155.             ALT-RIGHT SHIFT: Clear the keyboard buffer
  156.                  
  157.                  You may clear the typeahead buffer by pressing the ALT
  158.                  and RIGHT SHIFT keys simultaneously.  This clears
  159.                  anything in the buffer, even if you've already hit the
  160.                  ENTER key.  This function is not active when FASTBUFF
  161.                  is turned off.
  162.             
  163.             The rest of the keys are entered by pressing keys while
  164.             holding down the FASTBUFF command key.  This key has been
  165.             chosen to be the "5" key located on your numeric keypad, in
  166.             an effort to clash with as few other resident programs as
  167.             possible.  I will denote this key as [5] from here on out.
  168.             You must also note that this key is distinct from the "5"
  169.             key located in the top row of the keyboard.
  170.             
  171.             
  172.             [5]-MINUS: Set repeat rate slow
  173.                  
  174.                  By pressing the [5] and the "-" key located right next
  175.                  to it you may set FASTBUFF to use its slower repeat
  176.                  rate (18 characters per second).  Note that this is
  177.                  still somewhat faster than the normal repeat rate.
  178.                  Most of the time this mode will also produce a
  179.                  "smoother" repeat.
  180.             
  181.             
  182.             [5]-PLUS: Set repeat rate fast
  183.                  
  184.                  The default setting for FASTBUFF is the fast repeat
  185.                  rate (36 characters per second).  However, this is too
  186.                  fast for some applications, so you may switch between
  187.                  the fast and slow modes to suit your needs.
  188.             
  189.             
  190.             [5]-DEL: Turn off FASTBUFF
  191.                  
  192.                  This version of FASTBUFF has been rewritten to conflict
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.                  with as few other programs as possible.  You shouldn't
  206.                  find too many programs that will require you to turn
  207.                  FASTBUFF off.  On the other hand, you may occasionally
  208.                  wish to reduce the keyboard buffer and repeat rates to
  209.                  the normal values and this switch allows you to do just
  210.                  that.
  211.             
  212.             
  213.             [5]-INS: Turn FASTBUFF back on
  214.                  
  215.                  If you've turned off FASTBUFF, you can re-enable it by
  216.                  pressing these keys simultaneously.
  217.             
  218.             
  219.                            COMMAND LINE SETUP PARAMETERS
  220.             
  221.             I've tried to set the defaults for FASTBUFF the way most
  222.             people will like them.  However, if there is something you
  223.             would like different there are a few startup values you may
  224.             change.  To do this you may enter setup codes on the command
  225.             line after the file name.  For example:
  226.             
  227.                  FASTBUFF /b255/v0/d9/s <ENTER>
  228.             
  229.             would set the buffer to 255 characters, the video blanking
  230.             off, the character repeat delay to about a half second and
  231.             the repeat rate to 18 characters per second (FASTBUFF's slow
  232.             repeat).
  233.             
  234.             Each parameter consists of a slash "/", the parameter letter
  235.             and finally a number, if one is required.  These may be
  236.             entered in any order, and even repeated.  When a parameter
  237.             is repeated the rightmost one takes precedence.
  238.             
  239.             FASTBUFF will not be installed if an invalid parameter is
  240.             entered, instead you will get a help screen.  You may get
  241.             this help screen at any time by typing:
  242.             
  243.                  FASTBUFF ? <ENTER>
  244.             
  245.             The help screen provides information on both the command
  246.             line parameters and the run-time command keys.
  247.             
  248.             
  249.                                PARAMETER DESCRIPTIONS
  250.             
  251.             /Bn  : Set buffer size
  252.                  
  253.                  If you can actually type fast enough to fill the
  254.                  default buffer you may wish to select a larger one by
  255.                  using this parameter.  Valid sizes are from 25 to 269.
  256.                  Note that FASTBUFF will accept numbers larger than 269,
  257.                  but the value actually used will be seemingly random.
  258.                  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.             
  272.             
  273.             /Vn  : Set screen blanking delay
  274.                  
  275.                  The amount of time FASTBUFF will wait for some form of
  276.                  input or screen I/O before blanking the screen may be
  277.                  set with this parameter.  Valid numbers range from 0 to
  278.                  60 minutes.  Again, larger numbers may be entered, but
  279.                  will produce delay times ranging from 1 to 60 minutes
  280.                  anyway.  Setting the blanking delay to zero will
  281.                  disable it.
  282.             
  283.                  The video blanking has been tested with CGA, monochrome
  284.                  (Hercules also) and EGA cards.  It works fine with all
  285.                  except the EGA.  If you have this type of video card,
  286.                  or others not listed, it is suggested that you disable
  287.                  screen blanking just to be safe.  When I get some time
  288.                  and some more references I'll put together another
  289.                  version that supports other cards.
  290.             
  291.             /Dn  : Set repeat delay
  292.                  
  293.                  This parameter sets the amount of time (in timer
  294.                  clicks) a key must be held before it is repeated.  The
  295.                  default setting is 5 clicks, which translates to about
  296.                  a quarter of a second.  I believe the BIOS repeat delay
  297.                  is somewhere around 9 (a half second) and you may
  298.                  prefer that delay.
  299.             
  300.             
  301.             /F   : Select fast repeat rate
  302.                  
  303.                  Actually, there isn't really any reason for this option
  304.                  since the default setting is fast.  I included it
  305.                  mostly for consistency.  The fast repeat rate is 36
  306.                  characters per second.
  307.             
  308.             
  309.             /S   : Select slow repeat rate
  310.                  
  311.                  This parameter sets the repeat rate to FASTBUFF's
  312.                  slower rate, 18 characters per second.  The BIOS repeat
  313.                  rate seems to be about 9 char/second, so FASTBUFF is
  314.                  still quick, even in its slow mode.  Note that setting
  315.                  the fast or slow repeat rate only affects the startup
  316.                  mode, the repeat rate may still be switched at any time
  317.                  by using the run-time commands listed above.
  318.             
  319.             
  320.                                      SPECIFICS
  321.             
  322.             
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.             Now we will start getting a little more specific about what
  338.             each of these functions do.  This may (or may not) be
  339.             helpful for those of you mucking about in the source code.
  340.             
  341.             
  342.                                        HOOKS
  343.             
  344.             If you've had your computer for long, you've probably
  345.             already heard too much about hooking vectors and related
  346.             quirks of the IBM.  Sorry, but FASTBUFF is something of a
  347.             "system" program rather than an "application" and hooking is
  348.             a requirement (wipe that smirk off your face).
  349.             
  350.             In order to get all of the FASTBUFF features we only had to
  351.             hook into three interrupt vectors, although we considered a
  352.             few others.  Here is a list of the vectors and why we use
  353.             (or didn't use) them:
  354.             
  355.             09H : Keystroke
  356.                  
  357.                  We had to take over this vector in order to steal
  358.                  characters from the BIOS input buffer and put them into
  359.                  ours as they were typed.  Well, as long as we've taken
  360.                  over the keystroke interrupt why not make our control
  361.                  key something that isn't likely to conflict with other
  362.                  programs (like the five on the numeric keypad).
  363.                  
  364.                  Hey, we can fix that silly bug with our BIOS that won't
  365.                  let us enter graphics characters on the keypad too.
  366.             
  367.             (16H : Keyboard I/O)
  368.                  
  369.                  Well, now we need to be able to get those characters
  370.                  back out of our new buffer, since we've stolen them
  371.                  from the BIOS.  We could take over this interrupt and
  372.                  return characters from our buffer whenever the system
  373.                  asks for keyboard input, but it turns out that this
  374.                  isn't a good idea.
  375.                  
  376.                  The problem is that there are just too many programs
  377.                  that access the BIOS keyboard buffer directly, without
  378.                  consulting the system.  Another, less obvious problem,
  379.                  is that if we completely take over parts of this
  380.                  interrupt, we don't pass control on to the next program
  381.                  that hooked this vector.  This is becomes a problem
  382.                  when such programs are loaded before FASTBUFF.
  383.                  
  384.                  If you've already seen FASTBUFF v1.0 you know that this
  385.                  was the original design.  Version 2.0 uses the method
  386.                  described under interrupts 08 and 1C, and is much less
  387.                  likely to cause problems with other programs.
  388.             
  389.             (08H : Hardware Timer Interrupt)
  390.                  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.                  Lets see... If we don't use interrupt 16 to return
  404.                  characters, what are we going to do?  Well lets try
  405.                  checking once in a while to see if the normal BIOS
  406.                  buffer is full and if not insert characters from our
  407.                  buffer into the BIOS buffer.  The only reliable way to
  408.                  do this is to hook into the timer click interrupt.
  409.                  This allows us to perform this check 18.2 times per
  410.                  second (how often this interrupt is generated by the
  411.                  system).
  412.                  
  413.                  Well, we have the right notion, but we really shouldn't
  414.                  use the hardware interrupt for this.  The problem is
  415.                  that the system performs important actions every time
  416.                  this interrupt is issued, and if we take control first
  417.                  we will slow down its response.  The "proper" method
  418.                  uses the next interrupt.
  419.             
  420.             1CH : Get Control on Timer Tick
  421.                  
  422.                  This interrupt was provided by the system to allow
  423.                  actions of just the type we want.  If we're careful we
  424.                  can insert our code and pass control on to other
  425.                  programs that hook this vector with no problems.
  426.                  
  427.                  Now, we already know that we are going to be using this
  428.                  interrupt to update the BIOS buffer, so as long as
  429.                  we're here let's add another function that has a
  430.                  reasonable low overhead.
  431.                  
  432.                  Lets set up a counter to keep track of how long its
  433.                  been since the last screen I/O operation was performed.
  434.                  If the computer sits unattended for too long we can
  435.                  then blank the screen to avoid damaging the monitor.
  436.                  To do this right we'll have to reset the counter every
  437.                  time a key is pressed or something is written to the
  438.                  screen, which means we'll have to hook one more vector.
  439.             
  440.             10H : Video I/O
  441.                  
  442.                  To reset our screen blanking cursor when a key is
  443.                  pressed is no problem, we can just insert a few lines
  444.                  of code in our interrupt 9 handler.  However to detect
  445.                  if something is written to the screen we must take over
  446.                  this interrupt.  When a program is accessing the video
  447.                  in the "proper" way it will use this function interrupt
  448.                  to make changes to the screen.  Therefore we should
  449.                  reset our screen blanking counter whenever this
  450.                  interrupt is used.
  451.                  
  452.                  Again, there are some problems.  For example, many
  453.                  programs write to the screen directly and never bother
  454.                  the system with an interrupt 10 call.  For the video
  455.                  blanking this really isn't very serious since the worst
  456.                  that could happen is that the screen gets blanked when
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.                  there really is some activity.  All the user will have
  470.                  to do is type any key and the screen will be restored
  471.                  by our interrupt 9 reset function.
  472.                  
  473.                  Finally, we decide to add one more frill.  We'll give
  474.                  FASTBUFF some way to indicate that it is present if
  475.                  someone asks nicely.  This will enable us to detect if
  476.                  FASTBUFF is present when the program is executed and
  477.                  abort the installation in order to avoid having two
  478.                  copies in memory.
  479.                  
  480.                  We will add this feature as part of our interrupt 10
  481.                  handler for two reasons.  The reason for choosing an
  482.                  interrupt to perform this function is that we don't
  483.                  know where in memory a previous copy of FASTBUFF might
  484.                  be located, so we need this alternate method for
  485.                  detecting it.  We choose interrupt 10 to perform this
  486.                  function since it is the only one we have hooked that
  487.                  normally accepts input parameters and returns output.
  488.             
  489.             
  490.             Note that in the above list the interrupt vectors listed in
  491.             parenthesis are not actually used by FASTBUFF, they are
  492.             listed only as alternative considerations.
  493.             
  494.             Well that list should give you a feel for how FASTBUFF
  495.             works.  Of course, I didn't actually design it in that
  496.             manner, I used a much more professional approach (I wrote
  497.             version 1.0 and started discovering bugs a couple of days
  498.             later).
  499.             
  500.             
  501.                                   THE SOURCE CODE
  502.             
  503.             
  504.             In this section I'll go over what each interrupt handler in
  505.             the source code does, in a general manner.  I won't cover
  506.             the initialization code, other than detecting if FASTBUFF is
  507.             installed, since that stuff is small potatoes.
  508.             
  509.             If you don't fully understand interrupt vectors yet, there
  510.             isn't much I can help you with here.  There are entire books
  511.             written on the subject.
  512.             
  513.             
  514.                                  INT 9 - KEYSTROKE
  515.             
  516.             The first thing I should note here is how and when this
  517.             interrupt is called.  This interrupt is issued every time a
  518.             key is pressed or released.  The keyboard returns the scan
  519.             code (a byte) through one of the input ports to let the
  520.             computer know which key it was.
  521.             
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.             The scan codes that have meaning to us are defined in the
  536.             equates set in the first section of the source code.  These
  537.             codes are for the "make" signals, or when the key is
  538.             depressed.  The "break" code, or when the key is released,
  539.             can be calculated by setting the high bit of the make code
  540.             (code+80H).
  541.             
  542.             Another note is that FASTBUFF keeps all of its status
  543.             information in a single byte.  We use the bits in this byte
  544.             (switches) to indicate certain conditions in FASTBUFF.  The
  545.             bits will be accessed by anding and oring the status byte
  546.             with masks that we set in the equates section of the code.
  547.             
  548.             
  549.             Setup:
  550.                  
  551.                  When we enter this interrupt there are a few things we
  552.                  must do along the lines of resetting FASTBUFF.  The
  553.                  first such item is turning off our repeat switch bit
  554.                  (repmask).  This is done so FASTBUFF won't continue to
  555.                  repeat a character after another key is pressed.
  556.                  
  557.                  Next we set the ES register so we can use it to access
  558.                  the BIOS data used by the rest of the system.  After
  559.                  doing this we reset the BIOS break detection bit.  We
  560.                  do this so we can test it again after the old interrupt
  561.                  9 call in order to see if we need to clear our buffers.
  562.             
  563.             Video counter:
  564.                  
  565.                  The next item we should take care of is resetting our
  566.                  video blanking counter.  If this interrupt is called
  567.                  the user must have typed some key, so we should start
  568.                  the blanking countdown again.
  569.                  
  570.                  A related check is to see if the video is currently
  571.                  shut off.  If the user was gone for a while and the
  572.                  screen was shut off we now need to turn it back on
  573.                  since they are obviously back.
  574.             
  575.             Command Key Check:
  576.                  
  577.                  Next we need to see if the command key is currently
  578.                  pressed.  We keep track of this by setting a bit
  579.                  (ctrlmodemask) in our FASTBUFF status byte when the [5]
  580.                  key is pressed.  We leave this bit set until we receive
  581.                  the scan code indicating that the [5] key was released.
  582.                  
  583.                  If the command mode bit is set we then need to see if
  584.                  second key in a control key combination was pressed.
  585.                  If one of the two combinations were pressed for turning
  586.                  FASTBUFF on or off then we need to set the appropriate
  587.                  bit in our status byte (fbmask).  If FASTBUFF is turned
  588.                  on or off we need to clear our keyboard buffer just to
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.                  be certain there aren't any problems caused by the
  602.                  switch.
  603.                  
  604.                  Note that even when we intercept these command keys
  605.                  that we still pass control on to the old interrupt
  606.                  handler, even though we ignore any characters it may
  607.                  have tried to put in the BIOS buffer.  This pass is
  608.                  done to minimize the possibility of FASTBUFF clobbering
  609.                  another resident program.
  610.                  
  611.                  Next, if FASTBUFF is on, we need to check for the key
  612.                  combinations that are used to set the key repeat speed.
  613.                  We don't perform this check when FASTBUFF is off, again
  614.                  to minimize clashing with other resident utilities.
  615.             
  616.             FASTBUFF on/off:
  617.                  
  618.                  At this point we have taken care of all the required
  619.                  resettings and checks so we may finally check if
  620.                  FASTBUFF is active.  If FASTBUFF is currently turned
  621.                  off we may safely make the call to the old interrupt 9
  622.                  handler and exit the interrupt call.
  623.             
  624.             First Alt-Key Break Check:
  625.                  
  626.                  One of the things FASTBUFF is supposed to do is take
  627.                  care of the Alt-keypad entries and make sure they are
  628.                  returned in the standard IBM BIOS format.  The first
  629.                  step in this direction is to watch for the scan code
  630.                  that indicates that the ALT key was released.
  631.                  
  632.                  If this code is detected we will steal a copy of the
  633.                  character number created by the BIOS.  This character
  634.                  is stored in a byte in the BIOS data area
  635.                  (BIOSaltbuff).  We need to store it now since it will
  636.                  be zeroed when the call to the old interrupt 9 handler.
  637.             
  638.             Check for Clear Key Combination:
  639.                  
  640.                  Another control-type key we need to check for is the
  641.                  CTRL-RIGHT SHIFT clear buffer combination.  If this key
  642.                  is detected (while FASTBUFF is active) we need to clear
  643.                  out the buffer.
  644.             
  645.             Call Old Interrupt Handler:
  646.                  
  647.                  If we make it this far without encountering a control
  648.                  key we finally call the old keystroke interrupt
  649.                  handler.  We are doing this for two reasons: its a good
  650.                  idea to pass control on to the old one and there is no
  651.                  reason to duplicate the BIOS code that translates the
  652.                  keyboard scan codes into ASCII characters.
  653.                  
  654.                  Something that I'll cover in more detail later is the
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.                  reason for setting a bit in our status byte that
  668.                  indicates we are calling the old interrupt 9 handler.
  669.                  
  670.                  After calling the old BIOS handler we can tell if a
  671.                  character was entered by whether or not the BIOS tail
  672.                  pointer has moved.  After storing this character and
  673.                  checking for a new character we restore the old value
  674.                  of the BIOS tail pointer.  This effectively removes the
  675.                  character from the BIOS buffer.
  676.             
  677.             CTRL-BREAK Check:
  678.                  
  679.                  We now need to check the CTRL-BREAK bit again to see if
  680.                  that key combination was pressed.  If so we have to
  681.                  clear the buffers and output a dummy character.  The
  682.                  dummy character is done to emulate the way the normal
  683.                  BIOS returns a CTRL-BREAK sequence.
  684.             
  685.             New Character Detected:
  686.                  
  687.                  If a new character was input we need to remove it from
  688.                  the BIOS keyboard buffer and insert into ours.  Before
  689.                  we insert the character we want to check again to see
  690.                  if it was entered via the keypad.  If so we must first
  691.                  fix the character code to be inserted.
  692.                  
  693.                  The fix for these characters simply consists of
  694.                  retrieving the character we saved earlier and forcing
  695.                  it into the standard format.  The standard format is
  696.                  just the ASCII code in the low byte and a zero in the
  697.                  high byte.  If your system already does this correctly,
  698.                  then the fix doesn't hurt anything anyway.
  699.                  
  700.                  The actual insertion of the character into our buffer
  701.                  will be covered in the next section.
  702.             
  703.             
  704.                            PUT CHARACTER INTO OUR BUFFER
  705.             
  706.             Last Character:
  707.                  
  708.                  This check is done to make sure that the character just
  709.                  just entered did not come from the standard BIOS repeat
  710.                  function.  If the character input matches the last one
  711.                  typed it may be assumed that the scan code came from
  712.                  the standard repeat and we will ignore it.  The
  713.                  character is ignored in order to avoid a repeat speed
  714.                  that looks jerky.
  715.                  
  716.                  Note that we may assume that a character that matches
  717.                  the lastchar value is from the standard repeat since we
  718.                  would see the break scan code if the key was released.
  719.             
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.             Repeat Delay:
  734.                  
  735.                  There are two variables that must be set for use later
  736.                  by the repeat function.  The first is the one mentioned
  737.                  above.  We need to keep track of the last character
  738.                  entered for use by the repeat function.  Since this is
  739.                  a new character we set the counter for the repeat delay
  740.                  to its starting value.
  741.             
  742.             Increment Tail Pointer:
  743.                  
  744.                  The next step is to increment the tail pointer on our
  745.                  buffer.  If this incremented value matches the head
  746.                  pointer then the buffer is full and we need to beep to
  747.                  tell the user.
  748.             
  749.             Turn the repeat function on:
  750.                  
  751.                  Since we detected a new typeable character we need to
  752.                  turn the repeat function back on.  This tells the
  753.                  interrupt 1C handler to repeat the character when it is
  754.                  called later.
  755.                  
  756.                  There is another modification that FASTBUFF makes to
  757.                  the character repeat function.  If the character was
  758.                  entered through the keypad its scan code will be zero.
  759.                  If this is true and the user is currently holding down
  760.                  the LEFT SHIFT key we will allow the character to
  761.                  repeat until the LEFT SHIFT is released.
  762.             
  763.             
  764.                                  INT 10 - VIDEO I/O
  765.             
  766.             Reset Blanking Counter:
  767.                  
  768.                  The first thing to do is reset the screen blanking
  769.                  cursor.  If the program performs any video output then
  770.                  we assume that the counter should be reset.
  771.             
  772.             Check if Video Disabled:
  773.                  
  774.                  After resetting the counter we still need to make sure
  775.                  the video is still on.  If it was disabled earlier the
  776.                  video active bit will have been cleared to let us know
  777.                  that we need to restore it.
  778.             
  779.             Function FAH:
  780.                  
  781.                  A final addition to this interrupt will be a way for
  782.                  FASTBUFF to indicate that it is resident.  This will
  783.                  allow us to avoid loading two copies of FASTBUFF.
  784.                  
  785.                  All we need to do to implement this is to check if the
  786.                  AH register contains FAH.  If it does we will return
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.                  00FAH in the entire AX register to let the calling
  800.                  program know we're resident.
  801.                  
  802.                  Unless there is some other application resident that
  803.                  doesn't behave properly this shouldn't cause a problem.
  804.                  The BIOS will normally ignore any function request it
  805.                  doesn't recognize.  The likelihood of some other
  806.                  resident program using function request FAH is pretty
  807.                  low.
  808.             
  809.             
  810.                                 INT 1C - TIMER TICK
  811.             
  812.             Check if FASTBUFF is on:
  813.                  
  814.                  The first thing for this interrupt handler is to make
  815.                  sure FASTBUFF is currently active.  If it isn't active
  816.                  then we aren't supposed to be doing anything here.
  817.             
  818.             Decrement Blanking Counter:
  819.                  
  820.                  If the program is active then we need to decrement the
  821.                  counter that lets us know when the screen is to be
  822.                  blanked.
  823.             
  824.             Video Blanking Check:
  825.                  
  826.                  When the counter reaches zero we still have to make
  827.                  sure that the video blanking option is enabled.  If the
  828.                  screen is supposed to be blanked then we call the
  829.                  routine that does this and clear the bit that indicates
  830.                  the screen is active.
  831.             
  832.             Update BIOS Buffer:
  833.                  
  834.                  As mentioned earlier we aren't using the keyboard i/o
  835.                  interrupt to return characters to the system.  We chose
  836.                  this method to improve compatibility with other
  837.                  programs.
  838.                  
  839.                  The updateBIOS procedure will be covered in the next
  840.                  section, but for now we should note the check with the
  841.                  oldint9mask.  This check is done to make sure we aren't
  842.                  currently making a call to the old interrupt 9 handler.
  843.                  If we were to try to add characters while BIOS is
  844.                  trying to take them out we will occasionally lose a
  845.                  character or two.  We set our own flag for this because
  846.                  the interrupt flag will be reset from within the old
  847.                  int 9 handler if we try to use the CLI instruction.
  848.             
  849.             Repeating Keys:
  850.                  
  851.                  If the repeat bit is still set from the interrupt 9
  852.                  call above then we need to repeat the character stored
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.                  as the lastchar.  This procedure will be described
  866.                  below.
  867.             
  868.             
  869.                                      UPDATEBIOS
  870.             
  871.             This method is used to increase compatibility with other
  872.             programs that may do low-level keyboard i/o.  Using this
  873.             method we are always transferring characters into the BIOS
  874.             buffer and letting the system to the retrieval for us.  This
  875.             also allows other programs to access the BIOS buffer
  876.             directly in order to get input.
  877.             
  878.             
  879.             Check FASTBUFF Buffer:
  880.                  
  881.                  Of course the first step in copying characters from our
  882.                  buffer to the BIOS buffer is to make sure we have
  883.                  something to insert.
  884.             
  885.             Transfer to BIOS:
  886.                  
  887.                  If there are characters to copy then we move as many as
  888.                  we can into the BIOS buffer.  We must, however, keep in
  889.                  mind that the old BIOS keystroke handler expects to put
  890.                  input characters into its buffer.  For this reason we
  891.                  must keep an extra space open for its use when we do
  892.                  the update, otherwise the BIOS routine will just beep
  893.                  at us when we call it.
  894.             
  895.             Minimum Buffer Size:
  896.                  
  897.                  Now that you know how this works I can explain why the
  898.                  minimum buffer size is set at 25.  In order to avoid a
  899.                  lot of special cases we need to make the minimum at
  900.                  least 15 (14 from the BIOS and 1 in our buffer).
  901.                  However, since we need to occasionally expand our
  902.                  buffer before the BIOS update this is not a good idea,
  903.                  FASTBUFF would then beep if only two characters were
  904.                  received in quick succession.
  905.                  
  906.                  The minimum of 25 allows 14 characters of BIOS storage
  907.                  and 16 in ours.  It is nearly impossible to type
  908.                  characters fast enough to fill our buffer before we get
  909.                  a chance to transfer some of them to the BIOS buffer.
  910.             
  911.                                    REPEATING KEYS
  912.             
  913.             Set Repeat Rate:
  914.                  
  915.                  The first thing that must be done after we deciding to
  916.                  repeat a key is to reset the repeat count to 1.  This
  917.                  allows us to check for a repeat on the next tick again.
  918.                  Back in the character input routines we set the repeat
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.                  count to the starting delay, which defaults to 5
  932.                  clicks.
  933.             
  934.             Anti-Skid Check:
  935.                  
  936.                  FASTBUFF uses a very simple check to make sure it is
  937.                  not going too fast for the application being used.  It
  938.                  just checks the BIOS buffer, and if its empty then we
  939.                  repeat the character, if not we can just wait till the
  940.                  next click and check again.
  941.                  
  942.                  Since we just checked to make sure the buffer was
  943.                  empty, and the minimum buffer size is 25 we know there
  944.                  won't be any problems with filling the buffer either.
  945.                  This allows us to repeat the character without
  946.                  bothering to check if the buffer overflows.
  947.             
  948.             Repeating the Key:
  949.                  
  950.                  Next we retrieve the character to be repeated and put 1
  951.                  (slow repeat) or 2 (fast) copies of it into the BIOS
  952.                  buffer.  Note that we must insert more than one
  953.                  character per click to achieve repeat rates faster than
  954.                  18 characters per second.
  955.             
  956.             
  957.                                    INITIALIZATION
  958.             
  959.             As mentioned above, all I am going to cover here is the
  960.             check to see if FASTBUFF is already installed.  The method
  961.             was described above anyway, but I'll mention it again just
  962.             for the heck of it.
  963.             
  964.             Since we don't know where in memory FASTBUFF will be
  965.             installed we need some way other than just looking for a
  966.             certain string we may have placed in the code.  One approach
  967.             using this method would be to use the DOS call to get the
  968.             interrupt address for one of the vectors FASTBUFF hooks and
  969.             then look for such a search string assuming that was the
  970.             code segment for a previously installed FASTBUFF.  The
  971.             problem with this is that there may be another application
  972.             installed later that that hooks that vector also.
  973.             
  974.             Instead we will allow our interrupt 10 handler an extra
  975.             function.  When we send an function FAH request, FASTBUFF
  976.             will send back 00FAH in the AX register.  If we don't get
  977.             this code we should be able to assume that FASTBUFF is not
  978.             already present on the system.
  979.             
  980.             Another note on the initialization process is that we don't
  981.             enable FASTBUFF until well after we have initialized its
  982.             variables and hooked all the required vectors.  This is done
  983.             to prevent someone from typing ahead during the FASTBUFF
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.             initialization and only having part of the required routines
  998.             to handle the input.
  999.             
  1000.             Finally we print the initialization message well before
  1001.             hooking any vectors or enabling FASTBUFF.  This is because
  1002.             we are using a DOS call to write out output to the screen
  1003.             and the user can hit CTRL-BREAK during this message and halt
  1004.             the program.  If this were done after the vectors are hooked
  1005.             and before FASTBUFF terminates and remains resident the
  1006.             system will hang as soon as the next program is run, since
  1007.             the interrupt handlers will be overwritten at that time.
  1008.             
  1009.             
  1010.                                         BYE
  1011.             
  1012.             Well I hope someone finds this program useful.  Sorry I get
  1013.             write such long documentation, but I get started and then
  1014.             hate to leave anything out.
  1015.             
  1016.             If you find any bugs, or have any additional information you
  1017.             think I'll find useful please let me know:
  1018.             
  1019.                       David Steiner
  1020.                       [D.STEINER] on GEnie
  1021.                       2035 J Apt.6
  1022.                       Lincoln, NE  68510
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.